<template>
  <a-row type="flex" style="flex-flow: inherit;">
    <a-col :flex="toggle?'260px':'30px'" style="margin-right: 12px;background-color: #fff;">
      <depart-tree :rootOpened="true" :multi="false" @ok="getTreeData" @toggleBool="toggleBool" />
    </a-col>
    <a-col flex="auto">
      <a-card :bordered="false" style="margin-bottom: 10px">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <a-form-model layout="inline" ref="ruleForm" :model="queryParam">
            <z-form-item :datas="fieldArr" :form="queryParam" :gutter="8" :toggle="toggleSearchStatus">
              <a-col :span="4" slot="submit-action">
                <a-space :size="6">
                  <a-button type="primary" @click="onQuery" icon="search">查询</a-button>
                  <a-button @click="onResetForm" icon="reload">重置</a-button>
                </a-space>
              </a-col>
            </z-form-item>
          </a-form-model>
        </div>
      </a-card>
      <a-card :bordered="false">
        <!-- 操作按钮区域 -->
        <!--        <div class="table-operator">-->
        <!--          <div>-->
        <!--            <a-button>导出</a-button>-->
        <!--          </div>-->
        <!--        </div>-->
        <div style="margin-bottom: 20px">
          <a-alert type="info" banner closable>
            <div slot="message">
              在所人员数量<span>{{}}</span>人，其中介入审批中人数<span>{{}}</span>人，未申请人数<span>{{}}</span>人。
            </div>
          </a-alert>
        </div>
        <!-- 表格展示 -->
        <div class="table-page-content">
          <z-table
            ref="table"
            rowKey="id"
            :showAlert="false"
            :showSelection="false"
            :loading="loading"
            :columns="columns"
            :dataSource="pageData"
            @selectedRow="onSelectedRow"
            @change="onTableChange"
          />
        </div>
        <!--弹窗区域-->
        <handle-modal ref="handleModalRef" @ok="modalFormOk" />
        <special-population-modal ref="specialPopulationModalRef" />
      </a-card>
    </a-col>
  </a-row>
</template>

<script>
import departTree from '../../modules/departTree'
import handleModal from '../../modules/handleModal'
import specialPopulationModal from '../../checkManage/specialPopulation/modules/AddModal'
import {listFor,listForm} from "@views/sjsk/modules/list";
import {pageNew} from "@api/sjsk/receiveCase";

export default {
  components: { departTree, handleModal, specialPopulationModal },
  mixins:[listFor,listForm],
  data() {
    return {

      lookTer:true,
      toggle: true,
      selectKeys: [],
      queryParam: {},
      /* 查询折叠 */
      toggleSearchStatus:true,
      fieldArr: [
        {label: '姓名', prop: 'name', tagType: 'input', span: 5},
        {label: '身份证号', prop: 'identification', tagType: 'input', span: 5},
        {label: '当前状态', prop: 'status', tagType: 'dict-select', dictCode:'sex', span: 5},
        {label: '监所类型', prop: 'dataType', tagType: 'dict-select', dictCode:'sex', span: 5}
      ],
      columns: [
        {
          title: '序号',
          dataIndex: 'order',
          width: 60,
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter.pageNo - 1) * this.pageFilter.pageSize + (index + 1)}` //序号分页后连续
        },
        {
          title: '个案编号',
          dataIndex: 'realName',
          width: 40,
          align: 'left',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '姓名',
          width: 40,
          align: 'left',
          dataIndex: 'sex',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '身份证号',
          dataIndex: 'identityCard',
          width: 110,
          align: 'left',
          customRender: text => {
            return <j-ellipsis value={text} length={20} />
          }
        },
        {
          title: '强戒所',
          dataIndex: 'durgRehabilitatioName',
          width: 60,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '当前状态',
          dataIndex: 'status',
          width: 80,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '截至日期',
          dataIndex: 'admissionTime',
          width: 100,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '决定机关',
          dataIndex: 'decisionOrgan',
          width: 80,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '监所类型',
          dataIndex: 'dataType',
          width: 80,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={14} />
          }
        },
        {
          title: '操作',
          width: 120,
          align: 'center',
          dataIndex: 'action',
          customRender: (text, record, index) => {
            return (
              <a-space size={6}>
                <a type="link" style={'padding:0'} onClick={event => this.handleModal(record)}>查看</a>
                <a type="link" style={'padding:0'} onClick={event => this.handleModal(record)}>申请介入</a>
              </a-space>
            )
          }
        }
      ],
    }
  },
  created() {},
  async mounted() {
    this.onQuery()
  },
  methods: {
    onQuery() {
      console.log(this.queryParam)
      this.pageFilter.pageNo = 1
      this.refreshTable()
    },

    lookRouter(val){
      this.lookTer = val !== 1;
    },
    refreshTable() {
      let queryParam = Object.assign({}, this.queryParam, this.pageFilter)
      this.loading = true
      pageNew(queryParam)
        .then(res => {
          console.log(res)
          if (res.success) {
            this.pageData = res.result ? res.result : {}
            this.loading = false
            this.$refs.table.onClearRowKeys()
          } else {
            this.loading = false
          }
        })
        .catch(e => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
    },
    modalFormOk() {},
    // 弹窗操作
    handleModal(record) {
      this.$router.push({
        path:'/record/recordLook',
        query:{
          id:record.id
        }
      })
    },
    getTreeData(datas, id) {
      console.log(datas.id)
      // console.log(id)
    },
    toggleBool(bool) {
      console.log(bool)
      this.toggle = bool
    }
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
</style>
